package snmp;

import com.fasterxml.jackson.databind.ObjectMapper;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;

public class lldptest {
    private static String managerId;
    public lldptest(String managerId) {
        this.managerId = managerId;
    }

    public static String getManagerId() {
        return managerId;
    }
    private static OkHttpClient httpClient;
    private static ObjectMapper objectMapper;



    public static String PATH_MANAGERS_LLDPSERVICE = "/managers/{id}/lldpservice";
    public static void main(String[] args) throws Exception {
        httpClient = new OkHttpClient();
        objectMapper = new ObjectMapper();
        // LLDP 服务的路径,管理器的 ID
        String uri = uri(PATH_MANAGERS_LLDPSERVICE, getManagerId());
        try {
            // 创建 GET 请求
            Request request = new Request.Builder()
                    .url(uri)
                    .build();

            // 执行请求
            Response response = httpClient.newCall(request).execute();
            if (response.isSuccessful()) {
                // 读取响应体
                String responseBody = response.body().string();
                // 反序列化为 LldPServiceModel 对象
                LldPServiceModel entity = objectMapper.readValue(responseBody, LldPServiceModel.class);

            } else {
                throw new IOException("Unexpected response code: " + response);
            }
        } catch (IOException e) {
            // 处理异常
            System.err.println("Failed to retrieve LLDP data: " + e.getMessage());
            e.printStackTrace();
        }
    }

  public static String uri(String path, Object... params) {

      if (params.length == 0)
          return path;
      return String.format(path, params);
  }
}

